#include "polsys.h"
/******************************************************************************/
/*            Cortex-M4 Processor Exceptions Handlers                         */
/******************************************************************************/

/**
 * @brief  This function handles NMI exception.
 */
void NMI_Handler(void)
{
}

/**
 * @brief  This function handles Hard Fault exception.
 */
// void HardFault_Handler(void)
// {
//     /* Go to infinite loop when Hard Fault exception occurs */
//     while (1)
//     {
//     }
// }

/**
 * @brief  This function handles Memory Manage exception.
 */
void MemManage_Handler(void)
{
    /* Go to infinite loop when Memory Manage exception occurs */
    while (1)
    {
    }
}

/**
 * @brief  This function handles Bus Fault exception.
 */
void BusFault_Handler(void)
{
    /* Go to infinite loop when Bus Fault exception occurs */
    while (1)
    {
    }
}

/**
 * @brief  This function handles Usage Fault exception.
 */
void UsageFault_Handler(void)
{
    /* Go to infinite loop when Usage Fault exception occurs */
    while (1)
    {
    }
}

// /**
//  * @brief  This function handles SVCall exception.
//  */
// void SVC_Handler(void)
// {
// }

/**
 * @brief  This function handles Debug Monitor exception.
 */
void DebugMon_Handler(void)
{
}

// /**
//  * @brief  This function handles SysTick Handler.
//  */
// void SysTick_Handler(void)
// {
// }


/******************************************************************************/
/*                 N32G45X Peripherals Interrupt Handlers                     */
/*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
/*  available peripheral interrupt handler's name please refer to the startup */
/*  file (startup_n32g45x.s).                                                 */
/******************************************************************************/

#if APP_DRIVE_SELECT == 0

void RtPort_EvConsoleReceivedByte();
void Uart_SendComplete(uart_t *this);
void Uart_ReceivedByte(uart_t *this);

void USART1_IRQHandler(void)
{
    rt_interrupt_enter();
    if (USART_GetIntStatus(USART1, USART_INT_RXDNE) != RESET)   // 收到1个字节
    {
        Uart_ReceivedByte(&_UART_USART1_NAME);
        RtPort_EvConsoleReceivedByte();
        USART_ClrIntPendingBit(USART1, USART_INT_RXDNE);
    }

    if (USART_GetIntStatus(USART1, USART_INT_TXC) != RESET)    // 发送完毕1个字节
    {
        Uart_SendComplete(&_UART_USART1_NAME);
        USART_ClrIntPendingBit(USART1, USART_INT_TXC);
    }
    rt_interrupt_leave();
}
#endif





